Skip to main content
Feedback

Usage

When a request comes to this connector, it will check the body content type, and as per the requirement, it will convert the API payload content from XML to JSON and vice versa using pre-processing and post-processing.

JSON to XML Usage Examples

DescriptionJSON BodyTransformed XML Body
Normal JSON{"employee" : {"first-name" : "Jane","last-name" : "Doe","address" : "Paris","phone-number" : "123456"}}<?xml version="1.0" encoding="UTF-8"?><employee><first-name>Jane</first-name><last-name>Doe</last-name><address>Paris</address><phone-number>123456</phone-number></employee>
JSON with nested tag{"employee" : {"first-name" : "Jane","last-name" : "Doe","address" : {"street" : "123 A Street"},"phone-number" : "123456"}}<?xml version="1.0" encoding="UTF-8"?><employee><first-name>Jane</first-name><last-name>Doe</last-name><address><street>123 A Street</street></address><phone-number>123456</phone-number></employee>
JSON with attribute{"employee" : {"first-name" : "Jane","last-name" : "Doe","address" : {"street" : "123 A Street"},"phone-number" : \[ {"@type" : "work","\$" : "555-1111"}, {"@type" : "cell","$" : "555-2222"} ]}}<?xml version="1.0" encoding="UTF-8"?><employee><first-name>Jane</first-name><last-name>Doe</last-name><address><street>123 A Street</street></address><phone-number type="work">555-1111</phone-number><phone-number type="cell">555-2222</phone-number></employee>
JSON with empty object{"employee" : {"first-name" : "Jane","last-name" : "Doe","address" : {"street" : "123 A Street"},"phone-number" : [ {"@type" : "work","\$" : "555-1111"}, {"@type" : "cell","$" : "555-2222"} ],"other-details" : {}}}<?xml version="1.0" encoding="UTF-8"?><employee><first-name>Jane</first-name><last-name>Doe</last-name><address><street>123 A Street</street></address><phone-number type="work">555-1111</phone-number><phone-number type="cell">555-2222</phone-number><other-details></other-details></employee>

XML to JSON Usage Examples

DescriptionPre-Input DataXML BodyTransformed JSON BodyRemarks
Normal XML-<?xml version="1.0" encoding="UTF-8"?><employee><first-name>Jane</first-name><last-name>Doe</last-name><address>Paris</address><phone-number>123456</phone-number></employee>{"employee": {"first-name": "Jane","last-name": "Doe","address": "Paris","phone-number": 123456}}
XML with nested tag-<?xml version="1.0" encoding="UTF-8"?><employee><first-name>Jane</first-name><last-name>Doe</last-name><address><street>123 A Street</street></address><phone-number>123456</phone-number></employee>{"employee": {"first-name": "Jane","last-name": "Doe","address": {"street": "123 A Street"},"phone-number": 123456}}
JSON with attribute-<?xml version="1.0" encoding="UTF-8"?><employee><first-name>Jane</first-name><last-name>Doe</last-name><address><street>123 A Street</street></address><phone-number type="work">555-1111</phone-number><phone-number type="cell">555-2222</phone-number> </employee>{"employee": {"first-name": "Jane","last-name": "Doe","address": {"street": "123 A Street"},"phone-number": [{"@type": "work","$": "555-1111"},{"@type": "cell","\$": "555-2222"}]}}
Adding new nodenode_interpretation : stricttext_node_name : testNode<?xml version="1.0" encoding="UTF-8"?><catalog><book><name>bookName1</name></book></catalog>{"catalog": {"book": {"name": {"testNode": "bookName1"}}}}Both values - node_interpretation and text_node_name are mandatory in pre-input configuration to get the specific result. node_interpretation value should always be strict.Be sure to configure this both together in pre-inputs to add any text node
Add Custom Attribute prefixuse_attribute_prefix:yesattribute_prefix:#<?xml version="1.0" encoding="UTF-8"?><catalog><book id="01"><name>bookName1</name></book></catalog>{"catalog": {"book": {"#id": "01","name": "bookName1"}}}Both values -use_attribute_prefix and attribute_prefix are Mandatory in pre-input configuration to get the specific result. use_attribute_prefix value should always be yes.attribute_prefix must be used with use_attribute_prefix.
Namespace handlingnamespace_handling:yes<?xml version="1.0" encoding="UTF-8"?><test><pre:elem xmlns:pre="urn::value">xyz</pre:elem></test>{"test": {"pre:elem": {"xmlns:pre": "urn::value","$": "xyz"}}}To handle namespace, you must give namespace_handling:yes in pre-inputs.
Custom Name Space Prefixnamespace_handling:yes use_namespace_prefix:yes namespace_prefix:# <?xml version="1.0" encoding="UTF-8"?><test><pre:elem xmlns:pre="urn::value">xyz</pre:elem></test>{"test": {"pre:elem": {"#xmlns:pre": "urn::value","$": "xyz"}}}To handle namespace, these 3 values are required in pre-input configurations. This should be configured all together as given in the example.
Array Representation : Compactarray_representation : compact array_parent_child : options|option<?xml version="1.0" encoding="UTF-8"?><xml><options><option>1</option><option>2</option></options></xml>{"xml": {"options": [1,2]}}array_representation and array_parent_child must be used together to handle array representation. array_representation compact will create compact array as shown in the JSON example. array_representation and array_parent_child both should be configured together in pre-inputs to define array_representation. In case of multiple arrays in JSON, array_parent_child becomes a comma-separated list of parent|child
Array Representation : Expandedarray_representation : expand array_parent_child : options|option<?xml version="1.0" encoding="UTF-8"?><xml><options><option>1</option><option>2</option></options></xml>{"xml": {"options": {"option": [1,2]}}}Expand array_representation is default array_representation. If we are not giving any configuration in pre-inputs it will by default treat as expand.
Recognize Numberconsider_number:true<a><b>100</b><c>value</c></a>{"a": {"b": 100,"c": "value"}}This feature is applicable for XML→JSON transformation only.
consider_number:false<a><b>100</b><c>value</c></a>{"a": {"b": "100","c": "value"}}This feature is applicable for XML→JSON transformation only.
Recognize Booleanconsider_boolean:true<a><b>true</b><c>value</c></a>{"a": {"b": true,"c": "value"}}This feature is applicable for XML→JSON transformation only.
consider_boolean:false<a><b>true</b><c>value</c></a>{"a": {"b": "true","c": "value"}}This feature is applicable for XML→JSON transformation only.
On this Page